import { ApiProperty, OmitType } from '@nestjs/swagger';
import { UserEntity } from '../entities/user.entity';
import {
  SearchDto,
  SearchReturn,
} from 'src/common/decorators/search.decorator';

export class ListUserDto implements SearchDto {
  @ApiProperty({
    type: String,
    description: '页数',
    required: true,
    default: '1',
  })
  page: number;
  @ApiProperty({
    type: String,
    description: '每页分页数',
    required: true,
    default: '5',
  })
  pagesize: number;
}

class ListUserItem extends OmitType(UserEntity, ['role']) {}

export class ListUserReturn implements SearchReturn {
  @ApiProperty()
  total: number;
  @ApiProperty({ type: ListUserItem, isArray: true })
  rows: UserEntity[];
  @ApiProperty()
  page: number;
  @ApiProperty()
  pagesize: number;
}
